import apps from '@/view/App'
let id = 0
export default class Tab {
  constructor ({key, name, breadcrumbs, extra = {}}) {
    const app = apps.keyMap[key]
    this.key = key
    this.appKey = app.app
    this.name = name || app.name
    this.pid = '' + id++ // 唯一标识
    this.extra = extra
    this.breadcrumbs = breadcrumbs || app.breadcrumbs || []
  }

  setContainer (container) {
    this.container = container
  }

  close () {
    this.container.removeTab(this)
  }

  top () {
    this.container.topTab(this)
  }

  hide () {
    this.container.hideTab(this)
  }

  show () {
    this.container.showTab(this)
  }
}
